<?php


class Admin extends AdminBase {

	public function index(){
		$menu=$this->db->where('parent_id',0)->order_by("sort")->get('menu')->result_array();
		foreach ($menu as $k=>$v){
			$menu[$k]['son']=$this->GetMenu($v['id']);
			foreach ($menu[$k]['son'] as $k2=>$v2){
				$menu[$k]['son'][$k2]['son']=$this->GetMenu($v2['id']);
			}
		}

		$data['menu']=$menu;
		$this->load->view('index/index',$data);
	}


	public function main(){
		$beginToday=mktime(0,0,0,date('m'),date('d'),date('Y'));
		
		$sdefaultDate = date("Y-m-d");
        //$first =1 表示每周星期一为开始日期 0表示每周日为开始日期
        $first=1;
      //获取当前周的第几天 周日是 0 周一到周六是 1 - 6
        $w=date('w',strtotime($sdefaultDate));
       //获取本周开始日期，如果$w是0，则表示周日，减去 6 天
        $week_start=strtotime(date('Y-m-d',strtotime("$sdefaultDate -".($w ? $w - $first : 6).' days')));   
        
        $data['usertoday']=count($this->db->where('create_time >=',$beginToday)->get('user')->result_array());
        $data['userweek']=count($this->db->where('create_time >=',$week_start)->get('user')->result_array());
        
        $data['ordertoday']=count($this->db->where('create_time  >=',$beginToday)->get('order')->result_array());
        $data['orderweek']=count($this->db->where('create_time  >=',$week_start)->get('order')->result_array());
		$this->load->view('index/main',$data);
	}


}
